package main

import (
	"github.com/hashicorp/memberlist"
	"fmt"
	"time"
)

func main() {
	/* Create the initial memberlist from a safe configuration.
   Please reference the godoc for other default config types.
   http://godoc.org/github.com/hashicorp/memberlist#Config
*/
	list, err := memberlist.Create(memberlist.DefaultLocalConfig())
	if err != nil {
		panic("Failed to create memberlist: " + err.Error())
	}

	// Join an existing cluster by specifying at least one known member.
	_, err = list.Join([]string{"10.19.15.70", "10.1.130.13"})
	if err != nil {
		panic("Failed to join cluster: " + err.Error())
	}

	for  {
		// Ask for members of the cluster
		for _, member := range list.Members() {
			fmt.Printf("Member: %s %s\n", member.Name, member.Addr)
		}
		time.Sleep(time.Second * 2)
	}



	// Continue doing whatever you need, memberlist will maintain membership
	// information in the background. Delegates can be used for receiving
	// events when members join or leave.
	//orm.RunCommand()
	//beego.Run("0.0.0.0:9090")
}
